<template>
    <div class="layout">
        <div class="left">
            <textarea @keyup="transformData()" v-model="value1"></textarea>
        </div>
        <div class="center">
            &gt;
        </div>
        <div class="right">
            <textarea @keyup="transformData2()"  v-model="value2"></textarea>
        </div>
    </div>
</template>

<script>
import {base64Utils} from 'great-vue';
export default {
    name: "base64-demo01",
    data() {
        return {
            value1: '',
            value2: '',
        }
    },
    methods:{
        transformData(){
            const isBase64 = base64Utils.isBase64(this.value1);
            if(isBase64){
                this.value2 = base64Utils.decode(this.value1);
            }else{
                this.value2 = base64Utils.encode(this.value1);
            }
        },
        transformData2(){
            const isBase64 = base64Utils.isBase64(this.value2);
            if(isBase64){
                this.value1 = base64Utils.decode(this.value2);
            }else{
                this.value1 = base64Utils.encode(this.value2);
            }
        }
    }
}
</script>

<style scoped>
.layout{
    width:100%;
    height:500px;
    display: flex;
}
.layout .left,
.layout .right{
    flex: 1;
    padding:12px;
}
.layout textarea{
    width: 100%;
    height: 100%;
    resize:none;
    outline: none;
}
.layout .center{
    line-height: 450px;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
}
</style>
